<?php

class BaseController extends \Yaf\Controller_Abstract
{
    protected static $user_id;
    public function init(){
        static::$user_id=1;
    }
    public static function client($serviceName,$action,$params){
        \TC\Di\Container::set('service',[
            'class'  => 'TC\Sdk\Service',
            'redis'  =>  \TC\Di\Container::get('redis')
        ]);
        $service = \TC\Di\Container::get('service');
        $serviceConfig = $service->find($serviceName);
        $client = \TC\Di\Container::createObject($serviceConfig);
        return  $client->call($action,$params);
    }

//    public static function ResInfo($res){
//        if($res['code']){
//            exit(json_encode($res,JSON_UNESCAPED_UNICODE));
//        }
//        exit(json_encode(['msg'=>'网络错误','code'=>9909,'http_code'=>500,'data'=>[]],JSON_UNESCAPED_UNICODE));
//    }
}